/*
 * Copyright (c) 2009 Nathaniel Houghton <nathan@brainwerk.org>
 *                    Robert Kirchgessner <rkirchge@gmail.com>
 *
 * Permission to use, copy, modify, and distribute this software for
 * any purpose with or without fee is hereby granted, provided that
 * the above copyright notice and this permission notice appear in all
 * copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA
 * OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 * PERFORMANCE OF THIS SOFTWARE.
 *
 */

#ifndef NVM_HEADER
#define NVM_HEADER

#include <stdint.h>

#define NVM_READ 0x00
#define NVM_WRITE 0x01

#define NVM_SET 0x00
#define NVM_CLR 0x01

#define nvm_unlock() (nvm_status(NVM_WRITE, 0x00))

#define NVM_PAGE_SIZE 256
#define NVM_NUM_PAGES 4096
#define NVM_LAST_ADDR (NVM_PAGE_SIZE * NVM_NUM_PAGES - 1)

void nvm_read(void *, uint32_t, uint8_t);
uint8_t nvm_status(uint8_t, uint8_t);
void nvm_wel(uint8_t);
void nvm_write(uint32_t, void *, uint16_t);
int nvm_erase(void);

#endif
